<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateDepartmentManagerTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('department_manager', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '部门负责人表']);
        $table->addColumn(Column::integer('department_id')->setComment('部门ID'))
            ->addColumn(Column::string('leader_name')->setComment('负责人姓名'))
            ->addColumn(Column::string('leader_phone')->setDefault('')->setComment('负责人手机号'))
            ->addColumn(Column::string('leader_email')->setDefault('')->setComment('负责人邮箱'))
            ->addColumn(Column::enum('leader_type', ['CEO', 'GENERAL_MANAGER', 'DIRECTOR', 'MANAGER', 'TEAM_LEAD'])->setDefault('MANAGER')->setComment('负责人角色 CEO => 总裁 GENERAL_MANAGER => 总经理 DIRECTOR => 总监 MANAGER => 经理 TEAM_LEAD => 团队主管'))
            ->addColumn(Column::integer('create_time')->setComment('创建时间'))
            ->addColumn(Column::integer('update_time')->setComment('更新时间'))
            ->addColumn(Column::tinyInteger('is_delete')->setDefault(0)->setComment('是否删除 1是 0否'))
            ->addColumn(Column::integer('delete_time')->setComment('删除时间'))
            ->create();
    }
}
